from JSONLanguageReader import JSONLanguageReader

__author__ = 'deadmoroz'


class LanguageStorage(object):
    def __init__(self):
        self.__reader = JSONLanguageReader()
        self.__languages = {}

    def __load(self):
        languages = self.__reader.readAll()
        for language in languages:
            self.__languages[language.name] = language

    def __getitem__(self, name):
        if not self.__languages:
            self.__load()
        return self.__languages[name]
